"""
科目模型
"""
from sqlalchemy import Column, String, Text, DateTime, func
from sqlalchemy.orm import relationship
from .base import Base


class Subject(Base):
    """科目表"""
    __tablename__ = "subjects"
    
    name = Column(String(50), nullable=False, comment="科目名称")
    description = Column(Text, comment="科目描述")
    
    # 关系
    courses = relationship("Course", back_populates="subject")
    traffic_statistics = relationship("TrafficStatistics", back_populates="subject")
    
    def __repr__(self):
        return f"<Subject(id={self.id}, name='{self.name}')>"
